package org.example.intern.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.intern.entity.common.SysResume;
import org.example.intern.mapper.SysResumeMapper;
import org.example.intern.service.ISysResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class SysResumeServiceImpl extends ServiceImpl<SysResumeMapper,SysResume> implements ISysResumeService {

    @Autowired
    private SysResumeMapper sysResumeMapper;


    @Override
    public List<SysResume> selectByPage(Integer pageNum, Integer pageSize) {
        return sysResumeMapper.selectByPage(pageNum, pageSize);
    }

    @Override
    public Integer selectTotal() {
        return sysResumeMapper.selectTotal();
    }

    @Override
    public int deleteResume(Integer id) {
        return sysResumeMapper.deleteById(id);
    }


    @Override
    public int insert_update(SysResume sysResume) {
        if (sysResume.getId() == null) {
            Date now = new Date();
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            sysResume.setTime(dateFormat.format(now));
            return sysResumeMapper.insert(sysResume);
        }
        else {
            return sysResumeMapper.updateById(sysResume);
        }
    }

    @Override
    public int passResume(SysResume sysResume) {
        return sysResumeMapper.passResume(sysResume);
    }

    @Override
    public int backUpResume(SysResume sysResume) {
        return sysResumeMapper.backUpResume(sysResume);
    }
}
